/** @noSelf **/
export default class SyncUtil {

    /**
     * 可在异步里调用此方法
     */
    static SyncData(key: string, data = ""): void {
        DzSyncData(key, data)
    }


    /**
     * 只能在同步里调用此方法
     */
    static onSyncData(key: string, actionFunc: (triggerPlayer?: player, data?: string) => void): void {
        if (isAsync) {
            log.errorWithTraceBack("无法在异步中调用此方法！请在同步方法中执行！")
            return
        }
        let trigger = CreateTrigger();
        DzTriggerRegisterSyncData(trigger, key, false)
        TriggerAddAction(trigger, () => {
            let triggerPlayer = DzGetTriggerSyncPlayer();
            let data = DzGetTriggerSyncData();
            actionFunc(triggerPlayer, data)
        })
    }


}